import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Activities extends Thread {

	private static int numberOfBabyUnicorns;
	private static int numberOfMeals;
	private static int numberOfPots;
	private static int fullPots=0;
	private static ArrayList<BabyUnicorn> babies;
	private static ArrayList<BabyUnicorn> hungry;
	private static ArrayList<BabyUnicorn> eating;
	private static ArrayList<BabyUnicorn> readyToPlay;
	private static ArrayList<BabyUnicorn> playingUnicorns;
	private static ArrayList<Integer> groups;
 // Barrier feeding;
	Barrier playing;
	
	static Semaphore waitingToEat;
	static Semaphore sleepyMummy;
	static int blocking=0;
	
	public Activities(int m, int k, int n) {
		numberOfBabyUnicorns = n;
		numberOfPots = m;
		numberOfMeals = k;
		eating = new ArrayList<BabyUnicorn> ();
		babies = new ArrayList<BabyUnicorn>();
		hungry = new ArrayList<BabyUnicorn>();
		playingUnicorns = new ArrayList<BabyUnicorn>();
		readyToPlay = new ArrayList<BabyUnicorn>();
		groups = new ArrayList<Integer>();
		playing = new Barrier();
		
		sleepyMummy = new Semaphore();
		waitingToEat = new Semaphore();
		run();
	}
//////////////////////////////////////////////////////////////Run Method:
	public void run() {
		MotherUnicorn mom = new MotherUnicorn();
		
		for (int i = 0; i <  3*Activities.getNumberOfBabyUnicorns(); i++) {
			BabyUnicorn baby = new BabyUnicorn(i);
			System.out.println("babyunicorn id: " + baby.getBabyId());
			Activities.getBabies().add(baby);	
		}
	}
	

public static void printGroups(){
	System.out.println("size  " +readyToPlay.get(1).getBabyId());
	for (int i=0; i< readyToPlay.size();i=i+2){
		int player1 = readyToPlay.get(i).getBabyId();
		int player2 = readyToPlay.get(i+1).getBabyId();
		int player3 = readyToPlay.get(i+2).getBabyId();
		System.out.println("Unicorns playing together: "+ player1 + ", " + player2 + " and " + player3);
	}
}
	
	public synchronized void feeding () throws InterruptedException {
		for(int i=0; i<hungry.size(); i++) {
			hungry.get(i).eating();
		}
	}
	
	public static void main(String[]args) throws NumberFormatException, IOException {
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		System.out.println("please enter the number of Pots");
		int m = Integer.parseInt(stdin.readLine());
		System.out.println("please enter the number of meals");
		int k = Integer.parseInt(stdin.readLine());
		System.out.println("please enter the number of babyUnicorns");
		int n =Integer.parseInt(stdin.readLine());
		Activities a = new Activities(m,k,n);
	}
	
	
	
	public static int getNumberOfBabyUnicorns() {
		return numberOfBabyUnicorns;
	}
	public static void setNumberOfBabyUnicorns(int numberOfBabyUnicorns) {
		Activities.numberOfBabyUnicorns = numberOfBabyUnicorns;
	}
	public static int getNumberOfMeals() {
		return numberOfMeals;
	}
	public static void setNumberOfMeals(int numberOfMeals) {
		Activities.numberOfMeals = numberOfMeals;
	}
	public static int getNumberOfPots() {
		return numberOfPots;
	}
	public static void setNumberOfPots(int numberOfPots) {
		Activities.numberOfPots = numberOfPots;
	}
	public static int getFullPots() {
		return fullPots;
	}
	public static void setFullPots(int fullPots) {
		Activities.fullPots = fullPots;
	}
	public static ArrayList<BabyUnicorn> getBabies() {
		return babies;
	}
	public static void setBabies(ArrayList<BabyUnicorn> babies) {
		Activities.babies = babies;
	}
	public static ArrayList<BabyUnicorn> getHungry() {
		return hungry;
	}
	public static void setHungry(ArrayList<BabyUnicorn> hungry) {
		Activities.hungry = hungry;
	}
	public static ArrayList<BabyUnicorn> getEating() {
		return eating;
	}
	public static void setEating(ArrayList<BabyUnicorn> eating) {
		Activities.eating = eating;
	}
	public static ArrayList<BabyUnicorn> getReadyToPlay() {
		return readyToPlay;
	}
	public static void setReadyToPlay(ArrayList<BabyUnicorn> readyToPlay) {
		Activities.readyToPlay = readyToPlay;
	}
	public static ArrayList<BabyUnicorn> getPlayingUnicorns() {
		return playingUnicorns;
	}
	public static void setPlayingUnicorns(ArrayList<BabyUnicorn> playingUnicorns) {
		Activities.playingUnicorns = playingUnicorns;
	}
	public static ArrayList<Integer> getGroups() {
		return groups;
	}
	public static void setGroups(ArrayList<Integer> groups) {
		Activities.groups = groups;
	}
	
	public Barrier getPlaying() {
		return playing;
	}
	public void setPlaying(Barrier playing) {
		this.playing = playing;
	}
	
	public static Semaphore getWaitingToEat() {
		return waitingToEat;
	}
	public static void setWaitingToEat(Semaphore waitingToEat) {
		Activities.waitingToEat = waitingToEat;
	}
	public static Semaphore getSleepyMummy() {
		return sleepyMummy;
	}
	public static void setSleepyMummy(Semaphore sleepyMummy) {
		Activities.sleepyMummy = sleepyMummy;
	}

}
